<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      >
      	<f:metadata>
    	   <f:viewParam name="group" value="#{groupBean.groupId}"/>
	    </f:metadata>
      <head><title>IGNORED</title></head>
       <body>
      <ui:composition template="/templates/masterLayout.xhtml">
         <ui:define name="windowTitle">
            Группы
         </ui:define>
         <ui:define name="content">
         <h:panelGroup rendered="#{authBean.loggedIn and authBean.currentUser.isAdministrator}">
         <h2>Добавить группу</h2>
		<h:form>
<div>
    <h:outputLabel for="groupName" value="Название группы:" />
    <h:inputText id="groupName" value="#{groupBean.group.name}" required="true" />
</div>
<div>
    <h:outputLabel for="groupStartYear" value="Год поступления:" />
    <h:inputText id="groupStartYear" value="#{groupBean.group.startYear}" required="true" />
</div>
<div>
    <h:outputLabel for="groupTerms" value="Число семестров обучения:" />
    <h:selectOneMenu id="groupTerms" value="#{groupBean.group.terms}" required="true">
   		<f:selectItem itemValue="1" itemLabel="1"/>
   		<f:selectItem itemValue="2" itemLabel="2"/>
   		<f:selectItem itemValue="3" itemLabel="3"/>
   		<f:selectItem itemValue="4" itemLabel="4"/>
   		<f:selectItem itemValue="5" itemLabel="5"/>
   		<f:selectItem itemValue="6" itemLabel="6"/>
   		<f:selectItem itemValue="7" itemLabel="7"/>
   		<f:selectItem itemValue="8" itemLabel="8"/>
   		<f:selectItem itemValue="9" itemLabel="9"/>
   		<f:selectItem itemValue="10" itemLabel="10" />
   		<f:selectItem itemValue="11" itemLabel="11"/>
   		<f:selectItem itemValue="12" itemLabel="12"/>
    </h:selectOneMenu>
</div>
<div>
    <h:commandButton value="Добавить группу" action="#{groupBean.createGroup}" />
</div>
<div>
    <h:messages />
</div>
</h:form>
</h:panelGroup>
<div>
    <h:outputLabel for="output" value="Всего зарегистрировано групп: " />
    <h:outputText id="output" value="#{groupBean.groupsCount}" />
</div>
<div>
    <h:dataTable value="#{groupBean.groups}" var="g">
    <h:column>
        <f:facet name="header">
            <h:outputText value="Название группы" />
        </f:facet>
        <h:link outcome="publicMessages" includeViewParams="true" value="#{g.name}">
   			<f:param name="group" value="#{g.id}"/> 
		</h:link>
    </h:column>
    <h:column>
        <f:facet name="header">
            <h:outputText value="Год начала обучения" />
        </f:facet>
        <h:outputText value="#{g.startYear}" />
    </h:column>
    <h:column>
        <f:facet name="header">
            <h:outputText value="Число семестров обучения" />
        </f:facet>
        <h:outputText value="#{g.terms}" />
    </h:column>
     <h:column rendered="#{authBean.loggedIn and authBean.currentUser.isAdministrator}">
        <f:facet name="header">
            <h:outputText value="" />
        </f:facet>
        <h:form>
        	<h:commandButton value="Удалить" action="#{groupBean.deleteGroup}">
        		<f:param name="group" value="#{g.id}"/>
        	</h:commandButton>
        </h:form> 
    </h:column>
</h:dataTable>
</div>
         </ui:define>
      </ui:composition>
   </body>
 </html>
